#!/usr/bin/env bash

export MISE_PYTHON_DEFAULT_PACKAGES_FILE="$HOME/.default-python-packages"
export MISE_EXPERIMENTAL=1

cat >.mise.toml <<EOF
[env._.python]
venv = {path = "my_venv", create=true}
[tools]
python = "3.12.3"
uv = "0.5.4"
EOF

mise i
assert "mise x -- python --version" "Python 3.12.3"
assert_contains "mise x -- uv --version" "uv 0.5.4"
assert "mise env -s bash | grep VIRTUAL_ENV" "export VIRTUAL_ENV=$PWD/my_venv"
assert "mise x -- which python" "$PWD/my_venv/bin/python"
assert_not_contains "ls $PWD/my_venv/" "include" # stdlib virtual venv has an "include" folder while uv doesn't

## Allows opt-out uv's venv
#mkdir -p subdir
#cat >subdir/.mise.toml <<EOF
#[env._.python]
#venv = {path = "my_subvenv", create=true}
#[tools]
#python = "3.12.3"
#uv = "0.5.4"
#[settings]
#python_venv_stdlib = true
#EOF
#
#cd subdir || exit 1
#mise i
#assert "mise x -- python --version" "Python 3.12.3"
#assert "mise env -s bash | grep VIRTUAL_ENV" "export VIRTUAL_ENV=$PWD/my_subvenv"
#assert "mise x -- which python" "$PWD/my_subvenv/bin/python"
#assert_contains "ls $PWD/my_subvenv/" "include" # stdlib virtual venv has an "include" folder while uv doesn't
#
#cd .. || exit 1
#cat >.mise.toml <<EOF
#[tools]
#python = "3.12.3"
#uv = "0.5.4"
#[settings]
#python.uv_venv_auto = true
#EOF
#touch uv.lock
#
#assert "mise x -- which python" "$PWD/.venv/bin/python"
#assert "mise env -s bash | grep VIRTUAL_ENV" "export VIRTUAL_ENV=$PWD/.venv"
#assert "mise env -D | grep UV_PYTHON" "UV_PYTHON=3.12.3"
#assert_not_contains "ls $PWD/.venv" "include" # stdlib virtual venv has an "include" folder while uv doesn't
